//
//  MessageViewController.m
//  SheShiDu
//
//  Created by 泉  姜 on 16/6/23.
//  Copyright © 2016年 单剑秋. All rights reserved.
//

#import "MessageViewController.h"
#import "HouseViewController.h"


#define HEIGHT self.view.frame.size.height
#define WIDTH self.view.frame.size.width
@interface MessageViewController ()

@property (nonatomic, strong)HouseViewController *h;

@end

@implementation MessageViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.automaticallyAdjustsScrollViewInsets = NO;
    self.view.backgroundColor = [UIColor colorWithRed:28 / 255.0 green:186 / 255.0 blue:173 / 255.0 alpha:1];
    
    [self createAll];
    
    [self chooseOne];
    
    [self backItem];
}

- (void)backItem
{
    self.navigationController.navigationBar.tintColor = [UIColor blackColor];
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"back"] style:UIBarButtonItemStylePlain target:self action:@selector(left:)];
}

- (void)left:(UIBarButtonItem *)left
{
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)createAll
{
    self.backButton = [UIButton buttonWithType:UIButtonTypeSystem];
    _backButton.frame = CGRectMake(WIDTH * (255 / 375.0),HEIGHT * (444 / 667.0), WIDTH * (120 / 375.0), HEIGHT * (40 / 667.0));
    [self.view addSubview:_backButton];
//    _backButton.backgroundColor = [UIColor redColor];
    [_backButton addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
    [_backButton setTintColor:[UIColor blackColor]];
    [_backButton setTitle:@"回去瞅瞅?" forState:UIControlStateNormal];
    
    //    NSLog(@"%ld~~~~~~", _fuck);
    self.loveLabel = [[UILabel alloc] init];
//    _loveLabel.backgroundColor = [UIColor redColor];
    _loveLabel.frame = CGRectMake(WIDTH * (60 / 375.0), HEIGHT * (74 / 667.0), WIDTH * (255 / 375.0), HEIGHT * (60 / 667.0));
    _loveLabel.textAlignment = 1;
    _loveLabel.font = [UIFont systemFontOfSize:30];
    [self.view addSubview:_loveLabel];
    
    self.cadImgView = [[UIImageView alloc] init];
//    _cadImgView.backgroundColor = [UIColor redColor];
    _cadImgView.frame = CGRectMake(WIDTH * (20 / 375.0), HEIGHT * (144 / 667.0), WIDTH * (335 / 375.0), HEIGHT * (200 / 667.0));
    [self.view addSubview:_cadImgView];
    
    self.areaImgView = [[UIImageView alloc] init];
//    _areaImgView.backgroundColor = [UIColor redColor];
    _areaImgView.frame = CGRectMake(WIDTH * (20 / 375.0), HEIGHT * (354 / 667.0), WIDTH * (30 / 375.0), WIDTH * (30 / 375.0));
    [self.view addSubview:_areaImgView];
    
    self.areaLabel = [[UILabel alloc] init];
//    _areaLabel.backgroundColor = [UIColor redColor];
    _areaLabel.frame = CGRectMake(WIDTH * (60 / 375.0), HEIGHT * (354 / 667.0), WIDTH * (255 / 375.0), HEIGHT * (30 / 667.0));
    [self.view addSubview:_areaLabel];
    
    self.yearsImgView = [[UIImageView alloc]init];
//    _yearsImgView.backgroundColor = [UIColor redColor];
    _yearsImgView.frame = CGRectMake(WIDTH * (20 / 375.0), HEIGHT * (394 / 667.0), WIDTH * (30 / 375.0), WIDTH * (30 / 375.0));
    [self.view addSubview:_yearsImgView];
    
    self.yearsLabel = [[UILabel alloc] init];
//    _yearsLabel.backgroundColor = [UIColor redColor];
    _yearsLabel.frame = CGRectMake(WIDTH * (60 / 375.0), HEIGHT * (394 / 667.0), WIDTH * (255 / 375.0), HEIGHT * (30 / 667.0));
    [self.view addSubview:_yearsLabel];
    
    self.h = [[HouseViewController alloc]init];
}

- (void)chooseOne
{
    if (_fuck == 0) {
        _loveLabel.text = @"Living room";
        _cadImgView.image = [UIImage imageNamed:@"lroom"];
        _areaImgView.image = [UIImage imageNamed:@"area"];
        _areaLabel.text = @"建筑面积: 30.2m^2";
        _yearsImgView.image = [UIImage imageNamed:@"years"];
        _yearsLabel.text = @"距离竣工还有6天";
    } else if (_fuck == 1) {
        _loveLabel.text = @"Bedroom";
        _cadImgView.image = [UIImage imageNamed:@"bedroom"];
        _areaImgView.image = [UIImage imageNamed:@"area"];
        _areaLabel.text = @"建筑面积: 20.6m^2";
        _yearsImgView.image = [UIImage imageNamed:@"years"];
        _yearsLabel.text = @"距离竣工还有4天";
    } else if (_fuck == 2) {
        _loveLabel.text = @"Dining room";
        _cadImgView.image = [UIImage imageNamed:@"dining"];
        _areaImgView.image = [UIImage imageNamed:@"area"];
        _areaLabel.text = @"建筑面积: 18.6m^2";
        _yearsImgView.image = [UIImage imageNamed:@"years"];
        _yearsLabel.text = @"距离竣工还有11天";
    } else if (_fuck == 3) {
        _loveLabel.text = @"Kitchen";
        _cadImgView.image = [UIImage imageNamed:@"kitchen"];
        _areaImgView.image = [UIImage imageNamed:@"area"];
        _areaLabel.text = @"建筑面积: 21.6m^2";
        _yearsImgView.image = [UIImage imageNamed:@"years"];
        _yearsLabel.text = @"距离竣工还有16天";
    } else if (_fuck == 4) {
        _loveLabel.text = @"Toilet";
        _cadImgView.image = [UIImage imageNamed:@"toilet"];
        _areaImgView.image = [UIImage imageNamed:@"area"];
        _areaLabel.text = @"建筑面积: 18.4m^2";
        _yearsImgView.image = [UIImage imageNamed:@"years"];
        _yearsLabel.text = @"距离竣工还有5天";
    } else if (_fuck == 5) {
        _loveLabel.text = @"Balcony";
        _cadImgView.image = [UIImage imageNamed:@"balcony"];
        _areaImgView.image = [UIImage imageNamed:@"area"];
        _areaLabel.text = @"建筑面积: 23.4m^2";
        _yearsImgView.image = [UIImage imageNamed:@"years"];
        _yearsLabel.text = @"距离竣工还有9天";
    } else if (_fuck == 6) {
        _loveLabel.text = @"Study";
        _cadImgView.image = [UIImage imageNamed:@"study"];
        _areaImgView.image = [UIImage imageNamed:@"area"];
        _areaLabel.text = @"建筑面积: 19.4m^2";
        _yearsImgView.image = [UIImage imageNamed:@"years"];
        _yearsLabel.text = @"距离竣工还有5天";
    }else if (_fuck == 7) {
            _loveLabel.text = @"Hall";
            _cadImgView.image = [UIImage imageNamed:@"hall"];
            _areaImgView.image = [UIImage imageNamed:@"area"];
            _areaLabel.text = @"建筑面积: 10.2m^2";
            _yearsImgView.image = [UIImage imageNamed:@"years"];
            _yearsLabel.text = @"距离竣工还有19天";
    } else if (_fuck == 8) {
        _loveLabel.text = @"Cloakroom";
        _cadImgView.image = [UIImage imageNamed:@"cloakroom"];
        _areaImgView.image = [UIImage imageNamed:@"area"];
        _areaLabel.text = @"建筑面积: 17.9m^2";
        _yearsImgView.image = [UIImage imageNamed:@"years"];
        _yearsLabel.text = @"距离竣工还有15天";
    } else {
        _loveLabel.text = @"Garden";
        _cadImgView.image = [UIImage imageNamed:@"garden"];
        _areaImgView.image = [UIImage imageNamed:@"area"];
        _areaLabel.text = @"建筑面积: 40.8m^2";
        _yearsImgView.image = [UIImage imageNamed:@"years"];
        _yearsLabel.text = @"距离竣工还有13天";
    }
}

- (void)buttonAction:(UIButton *)button
{
//    [UIView transitionFromView:self.view toView:_h.view duration:0.5 options:UIViewAnimationOptionTransitionFlipFromRight completion:^(BOOL finished) {
//        
//    }];
    CATransition *animation = [CATransition animation];
    animation.duration = 0.4f;
    animation.type = kCATransitionFade;
//    animation.subtype = kCATransitionFromLeft;
    [self.navigationController.view.layer addAnimation:animation forKey:nil];
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
